﻿<UserControl x:Class="Seesmic.HelloTipi.Controls.ProfilControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:controls="clr-namespace:Seesmic.HelloTipi.Controls"
    xmlns:c="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
    xmlns:ct="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
    xmlns:helpers="clr-namespace:Seesmic.HelloTipi.Helpers" 
    xmlns:toolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
             xmlns:utils="clr-namespace:Seesmic.Sdp.Utils;assembly=Seesmic.Sdp.Utils"
             xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows"             
    mc:Ignorable="d"
    d:DesignHeight="800" d:DesignWidth="300">

    <Grid x:Name="LayoutRoot">
        <Grid.Resources>
            <Style x:Key="NoBorderStyle" TargetType="HyperlinkButton">
                <Setter Property="Foreground" Value="#FF73A9D8" />
                <Setter Property="Padding" Value="0,0,0,0"/>
                <Setter Property="Cursor" Value="Hand"/>
                <Setter Property="HorizontalContentAlignment" Value="Left"/>
                <Setter Property="VerticalContentAlignment" Value="Top"/>
                <Setter Property="Background" Value="Transparent" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="HyperlinkButton">
                            <Grid Cursor="{TemplateBinding Cursor}" Background="{TemplateBinding Background}">
                                <vsm:VisualStateManager.VisualStateGroups>
                                    <vsm:VisualStateGroup x:Name="CommonStates">
                                        <vsm:VisualState x:Name="Normal"/>
                                        <vsm:VisualState x:Name="MouseOver">
                                            <Storyboard>
                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="UnderlineTextBlock" Storyboard.TargetProperty="Visibility" Duration="0">
                                                    <DiscreteObjectKeyFrame KeyTime="0">
                                                        <DiscreteObjectKeyFrame.Value>
                                                            <Visibility>Visible</Visibility>
                                                        </DiscreteObjectKeyFrame.Value>
                                                    </DiscreteObjectKeyFrame>
                                                </ObjectAnimationUsingKeyFrames>
                                            </Storyboard>
                                        </vsm:VisualState>
                                        <vsm:VisualState x:Name="Pressed">
                                            <Storyboard>
                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="UnderlineTextBlock" Storyboard.TargetProperty="Visibility" Duration="0">
                                                    <DiscreteObjectKeyFrame KeyTime="0">
                                                        <DiscreteObjectKeyFrame.Value>
                                                            <Visibility>Visible</Visibility>
                                                        </DiscreteObjectKeyFrame.Value>
                                                    </DiscreteObjectKeyFrame>
                                                </ObjectAnimationUsingKeyFrames>
                                            </Storyboard>
                                        </vsm:VisualState>
                                        <vsm:VisualState x:Name="Disabled">
                                            <Storyboard>
                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="DisabledOverlay" Storyboard.TargetProperty="Visibility" Duration="0">
                                                    <DiscreteObjectKeyFrame KeyTime="0">
                                                        <DiscreteObjectKeyFrame.Value>
                                                            <Visibility>Visible</Visibility>
                                                        </DiscreteObjectKeyFrame.Value>
                                                    </DiscreteObjectKeyFrame>
                                                </ObjectAnimationUsingKeyFrames>
                                            </Storyboard>
                                        </vsm:VisualState>
                                    </vsm:VisualStateGroup>
                                    <!--<vsm:VisualStateGroup x:Name="FocusStates">
                                <vsm:VisualState x:Name="Focused">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="FocusVisualElement" Storyboard.TargetProperty="Opacity" Duration="0" To="1"/>
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="Unfocused"/>
                            </vsm:VisualStateGroup>-->
                                </vsm:VisualStateManager.VisualStateGroups>
                                <TextBlock
                          x:Name="UnderlineTextBlock"
                          Text="{TemplateBinding Content}"
                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                          Margin="{TemplateBinding Padding}"
                          TextDecorations="Underline"
                          Visibility="Collapsed"/>
                                <TextBlock Canvas.ZIndex="1"
                          x:Name="DisabledOverlay"
                          Text="{TemplateBinding Content}"
                          Foreground="#FFAAAAAA"
                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                          Margin="{TemplateBinding Padding}"
                          Visibility="Collapsed"/>
                                <ContentPresenter 
                          x:Name="contentPresenter"
                          Content="{TemplateBinding Content}"
                          ContentTemplate="{TemplateBinding ContentTemplate}"
                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                          Margin="{TemplateBinding Padding}"/>
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
            <helpers:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
            <helpers:UrlToUriConverter x:Key="UrlToUriConverter"/>
        </Grid.Resources>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" MinHeight="1" MaxHeight="280"/>
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <!-- Profile Picture -->
        <HyperlinkButton Grid.Row="0" NavigateUri="{Binding Contact.url, Converter={StaticResource UrlToUriConverter}}" Style="{StaticResource NoBorderStyle}" Height="Auto" MinHeight="1" MaxHeight="280" HorizontalContentAlignment="Center">
            <Image Height="Auto" MinHeight="1" MaxHeight="80" Margin="5" Stretch="Uniform" utils:WebImageHandler.ImageSource="{Binding ItemData.AvatarUri}" Loaded="Image_Loaded"
                    ToolTipService.ToolTip="Page de son profil sur HelloTipi"/>
        </HyperlinkButton>
        <!-- TabControl -->
        <c:TabControl Grid.Row="1" Margin="5,0,5,0" Background="#1a1c1e" Style="{StaticResource ProfileTabControl}" Name="MainTabControl">
            <c:TabItem Header="Profile" Style="{StaticResource ProfileTabItemControl}">

                <Border Background="{StaticResource ProfileTabBackground}">
                    <ct:DockPanel LastChildFill="True">

                        <ScrollViewer VerticalScrollBarVisibility="Auto">

                            <StackPanel>

                                <TextBlock ct:DockPanel.Dock="Top"
                                                       FontSize="16"
                                                       FontWeight="Bold"
                                                       Margin="8,4,0,0"
                                                       Text="{Binding Path=Contact.name}">
                                </TextBlock>

                                <TextBlock ct:DockPanel.Dock="Top"
                                                       FontSize="16"
                                                       FontWeight="Normal"
                                                       Margin="8,0,0,0"
                                                       Text="{Binding ItemData.UsernamewithoutFamily, StringFormat='@{0}'}" />


                                <RichTextBox ct:DockPanel.Dock="Top" IsReadOnly="True" BorderBrush="Transparent" Background="Transparent" TextWrapping="Wrap"  Margin="8,0,0,0">
                                    <Paragraph>
                                        <Hyperlink TextDecorations="None" NavigateUri="{Binding Path=Contact.url, Converter={StaticResource UrlToUriConverter}}" MouseOverForeground="#FFF8E500">
                                            <Run Text="Page de son profil sur HelloTipi" />
                                        </Hyperlink>
                                    </Paragraph>
                                </RichTextBox>


                               <StackPanel ct:DockPanel.Dock="Top" Margin="0,12,0,0" Visibility="{Binding Contact.email, Converter={StaticResource NullToVisibilityConverter}}">
                                    <TextBlock FontSize="10" Foreground="#808080" Margin="8,0,0,0">email</TextBlock>
                                    <TextBlock Margin="8,2,4,0" ct:DockPanel.Dock="Top" FontSize="14" TextWrapping="Wrap" LineHeight="16" LineStackingStrategy="BlockLineHeight" Text="{Binding Contact.email}" />
                                </StackPanel>

                                <StackPanel ct:DockPanel.Dock="Top" Margin="0,12,0,0" Visibility="{Binding Contact.birthday, Converter={StaticResource NullToVisibilityConverter}}">
                                    <TextBlock FontSize="10" Foreground="#808080" Margin="8,0,0,0">Anniversaire</TextBlock>
                                    <TextBlock Margin="8,2,4,0" ct:DockPanel.Dock="Top" FontSize="14" TextWrapping="Wrap" LineHeight="16" LineStackingStrategy="BlockLineHeight" Text="{Binding Contact.birthday}" />
                                </StackPanel>

                                <StackPanel ct:DockPanel.Dock="Top" Margin="0,12,0,0" Visibility="{Binding Contact.address_1, Converter={StaticResource NullToVisibilityConverter}}">
                                    <TextBlock FontSize="10" Foreground="#808080" Margin="8,0,0,0">Adresse</TextBlock>
                                    <TextBlock Margin="8,2,4,0" ct:DockPanel.Dock="Top" FontSize="14" TextWrapping="Wrap" LineHeight="16" LineStackingStrategy="BlockLineHeight" Text="{Binding Contact.address_1}" />
                                    <TextBlock Margin="8,2,4,0" ct:DockPanel.Dock="Top" FontSize="14" TextWrapping="Wrap" LineHeight="16" LineStackingStrategy="BlockLineHeight" Text="{Binding Contact.address_2}" />
                                </StackPanel>

                                <StackPanel ct:DockPanel.Dock="Top" Margin="0,12,0,0" Visibility="{Binding Contact.zip, Converter={StaticResource NullToVisibilityConverter}}">
                                    <TextBlock FontSize="10" Foreground="#808080" Margin="8,0,0,0">Code Postal</TextBlock>
                                    <TextBlock Margin="8,2,4,0" ct:DockPanel.Dock="Top" FontSize="14" TextWrapping="Wrap" LineHeight="16" LineStackingStrategy="BlockLineHeight" Text="{Binding Contact.zip}" />
                                </StackPanel>

                                <StackPanel ct:DockPanel.Dock="Top" Margin="0,12,0,0" Visibility="{Binding Contact.city, Converter={StaticResource NullToVisibilityConverter}}">
                                    <TextBlock FontSize="10" Foreground="#808080" Margin="8,0,0,0">Ville</TextBlock>
                                    <TextBlock Margin="8,2,4,0" ct:DockPanel.Dock="Top" FontSize="14" TextWrapping="Wrap" LineHeight="16" LineStackingStrategy="BlockLineHeight" Text="{Binding Contact.city}" />
                                </StackPanel>

                                <StackPanel ct:DockPanel.Dock="Top" Margin="0,12,0,0" Visibility="{Binding Contact.state, Converter={StaticResource NullToVisibilityConverter}}">
                                    <TextBlock FontSize="10" Foreground="#808080" Margin="8,0,0,0">Région</TextBlock>
                                    <TextBlock Margin="8,2,4,0" ct:DockPanel.Dock="Top" FontSize="14" TextWrapping="Wrap" LineHeight="16" LineStackingStrategy="BlockLineHeight" Text="{Binding Contact.state}" />
                                </StackPanel>

                                <StackPanel ct:DockPanel.Dock="Top" Margin="0,12,0,0" Visibility="{Binding Contact.country_name, Converter={StaticResource NullToVisibilityConverter}}">
                                    <TextBlock FontSize="10" Foreground="#808080" Margin="8,0,0,0">Pays</TextBlock>
                                    <TextBlock Margin="8,2,4,0" ct:DockPanel.Dock="Top" FontSize="14" TextWrapping="Wrap" LineHeight="16" LineStackingStrategy="BlockLineHeight" Text="{Binding Contact.country_name}" />
                                </StackPanel>

                                <StackPanel ct:DockPanel.Dock="Top" Margin="0,12,0,0" Visibility="{Binding Contact.phone_1, Converter={StaticResource NullToVisibilityConverter}}">
                                    <TextBlock FontSize="10" Foreground="#808080" Margin="8,0,0,0">Téléphone</TextBlock>
                                    <TextBlock Margin="8,2,4,0" ct:DockPanel.Dock="Top" FontSize="14" TextWrapping="Wrap" LineHeight="16" LineStackingStrategy="BlockLineHeight" Text="{Binding Contact.phone_1}" />
                                </StackPanel>

                                <StackPanel ct:DockPanel.Dock="Top" Margin="0,12,0,0" Visibility="{Binding Contact.phone_2, Converter={StaticResource NullToVisibilityConverter}}">
                                    <TextBlock FontSize="10" Foreground="#808080" Margin="8,0,0,0">Téléphone 2</TextBlock>
                                    <TextBlock Margin="8,2,4,0" ct:DockPanel.Dock="Top" FontSize="14" TextWrapping="Wrap" LineHeight="16" LineStackingStrategy="BlockLineHeight" Text="{Binding Contact.phone_2}" />
                                </StackPanel>
                            </StackPanel>
                        </ScrollViewer>
                    </ct:DockPanel>
                </Border>
            </c:TabItem>
           <c:TabItem Header="Famille" Style="{StaticResource ProfileTabItemControl}">
                <Border Background="{StaticResource ProfileTabBackground}">
                    <ct:DockPanel LastChildFill="True">

                        <ScrollViewer  VerticalScrollBarVisibility="Auto">

                            <StackPanel>

                                <TextBlock ct:DockPanel.Dock="Top"
                                                       FontSize="16"
                                                       FontWeight="Bold"
                                                       Margin="8,4,0,0"
                                                       Text="{Binding Path=ItemData.Site.title}"
                                                       TextWrapping="Wrap">

                                </TextBlock>

                                <StackPanel Orientation="Horizontal">
                                    <Image HorizontalAlignment="Center"
                                            VerticalAlignment="Center"
                                            Margin="5"
                                            Stretch="None"  
                                            Source="{Binding ItemData.Site.image_small}">
                                    </Image>

                                    <StackPanel Orientation="Vertical">

                                        <RichTextBox ct:DockPanel.Dock="Top" IsReadOnly="True" BorderBrush="Transparent" Background="Transparent" TextWrapping="Wrap" Margin="8,12,0,0">
                                            <Paragraph >
                                                <Hyperlink TextDecorations="None" NavigateUri="{Binding Path= ItemData.Source}" MouseOverForeground="#FFF8E500">
                                                    <Run FontSize="14" Text="{Binding Path=ItemData.Site.name}"/>
                                                </Hyperlink>
                                            </Paragraph>
                                        </RichTextBox>                                       
                                    </StackPanel>
                                </StackPanel>
                            </StackPanel>
                        </ScrollViewer>
                    </ct:DockPanel>
                </Border>
            </c:TabItem>
        </c:TabControl>
        
        
        <!--<StackPanel ct:DockPanel.Dock="Top" Margin="0,12,0,0" Visibility="{Binding Path=ItemData.Site.role, Converter={StaticResource NullToVisibilityConverter}}">
                                                    <TextBlock FontSize="10" Foreground="#808080" Margin="8,0,0,0">Rôle</TextBlock>
                                                    <TextBlock Margin="8,2,4,0" ct:DockPanel.Dock="Top" FontSize="14" TextWrapping="Wrap" LineHeight="16" LineStackingStrategy="BlockLineHeight" Text="{Binding ItemData.Site.role}" />
                                                </StackPanel>-->
        
        <!-- Buttons -->
        <Border Grid.Row="3" Margin="5,0,5,5" Style="{StaticResource ProfileBottomButtonBorder}">
            <StackPanel Orientation="Horizontal" Margin="0,-1,0,0">
                <Button HorizontalAlignment="Center" Content="Lui écrire en public" Command="{Binding SendPublicCommand}" Style="{StaticResource ProfileBottomButtonFirst}" Name="btnSendPublic"/>
                <Rectangle Width="1" Fill="#9000" />
                <Rectangle Width="1" Fill="#3FFF" />
                <Button HorizontalAlignment="Center" Content="Lui écrire en privée" Command="{Binding SendPrivateCommand}" Style="{StaticResource ProfileBottomButton}" Name="btnSendPrivate"/>
                <Rectangle Width="1" Fill="#9000" />
                <Rectangle Width="1" Fill="#3FFF" />
            </StackPanel>
        </Border>
        <!--Spinner animation ProgressBar-->
        <ProgressBar IsIndeterminate="{Binding LoadingInProgress}" Style="{StaticResource ProfileLoadingProgressBar}" Grid.RowSpan="3" />        
    </Grid>    
</UserControl>
